<template>
  <div class="zl-page">
    <iframe :src="href" frameborder="no" border="none" />
  </div>
</template>
<script type="text/javascript">

export default {
  data() {
    return {
      href: ''
    }
  },
  watch: {
    '$route'(val) {
      this.setUrl(val.query)
    }
  },
  mounted() {
    this.setUrl(this.$route.query)
  },
  methods: {
    setUrl(query) {
      if (query.self) {
        this.href = query.url
      } else {
        // eslint-disable-next-line no-undef
        const report = FRONT_CONFIG.report
        const loginid = query.loginid || report.loginid
        const pw = query.pw || report.pw
        const qy = query.qy || ''
        const resid = query.resid || ''
        let url = query.url || report.url
        if (!query.noparams) {
          url += '?calcnow=true&showmenu=false'
        } else {
          url += '?'
        }
        url += `&resid=${resid}&loginid=${loginid}&pw=${pw}`
        if (qy) {
          url += `qy=${qy}`
        }
        this.href = url
      }
    }
  }
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.zl-page {
  height: 100%;
  width: 100%;
  iframe {
    width: 100%;
    height: 100%;
  }
}
</style>
